﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;

public partial class Web_Business_Record_ContractArchive : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        hidHouseUrl.Value = System.Configuration.ConfigurationManager.AppSettings["WebRoot.House"] + "/HouseMgr.aspx";

        try
        {
            //从请求中获得房源ID
            string HouseId = Context.Request.Params["HouseId"];
            //从请求中获得标识ID
            string RecordId = Context.Request.Params["RecordId"];

            if (!string.IsNullOrEmpty(HouseId))
            {
                //获取相应房源信息
                Chenxin.Lib.House.Entity.House_BaseInfo entHouseInfo = Chenxin.Lib.House.BLL.House_BaseInfo.GetHouseInfoEntity(HouseId);
                //转成Json，发回客户端
                hidHouseInfo.Value = Chenxin.Lib.Utility.JsonHelp.Convert2Json(entHouseInfo);
            }
            else
            {
                if (!string.IsNullOrEmpty(RecordId))
                {
                    //报备信息业务类
                    Chenxin.Lib.Business.BLL.ContractArchive bllContractArc = new Chenxin.Lib.Business.BLL.ContractArchive();
                    //出售方信息业务类
                    Chenxin.Lib.Business.BLL.VenderInfo bllVender = new Chenxin.Lib.Business.BLL.VenderInfo();
                    //买方信息业务类
                    Chenxin.Lib.Business.BLL.BuyerInfo bllBuyer = new Chenxin.Lib.Business.BLL.BuyerInfo();

                    //获取相应房源信息
                    Chenxin.Lib.Business.Entity.t_Business_Record_BaseInfo entContractArc = bllContractArc.GetModel(new Guid(RecordId));
                    //出售方信息
                    List<Chenxin.Lib.Business.Entity.t_Business_Record_SubInfo1> lsVender = bllVender.GetModelListByMainId(RecordId);
                    //买方信息
                    List<Chenxin.Lib.Business.Entity.t_Business_Record_SubInfo2> lsBuyer = bllBuyer.GetModelListByMainId(RecordId);

                    if (entContractArc == null)
                    {
                        //Url参数出错，页面跳转
                        Context.Response.Redirect(string.Format(ErrorPageUrl, Resources.Message.Err_UrlError), false);
                    }

                    //转成Json，发回客户端
                    hidContractArc.Value = Chenxin.Lib.Utility.JsonHelp.Convert2Json(entContractArc);
                    //出售方信息
                    hidVenderInfo.Value = Chenxin.Lib.Utility.JsonHelp.Convert2Json(lsVender);
                    //买方信息
                    hidBuyerInfo.Value = Chenxin.Lib.Utility.JsonHelp.Convert2Json(lsBuyer);
                }
                else
                {
                    //Url参数出错，页面跳转
                    Context.Response.Redirect(string.Format(ErrorPageUrl, Resources.Message.Err_UrlError), false);
                }
            }
        }
        catch (Exception ex)
        {
            //Url参数出错，页面跳转
            Context.Response.Redirect(string.Format(ErrorPageUrl, ex.Message), false);
        }
    }
}
